package com.allen.controller;

import com.allen.bean.Comment;
import com.allen.bean.Result;
import com.allen.bean.Work;
import com.allen.service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: allen
 * @Data: 2021.06.18.20:38
 **/

@RestController    //相当于@Controller+@RequestBody
@RequestMapping("/comment")
@CrossOrigin(origins ="*")
public class CommentController {

    /**
     * 注入service层
     */
    @Autowired
    private CommentService commentService;

    /**
     * 测试入口
     */
    @RequestMapping("hello")
    public String hello(){
        return "hello";
    }
    /**
     * 查询评论
     * @param comment
     * @return
     */
    @RequestMapping("selc")
    public Result selc(Comment comment){
        System.out.println("成功进入控制器");
        return commentService.selComment(comment);
    }

    /**
     * 提交评论
     * @param comment
     * @return
     */
    @RequestMapping("subcm")
    public Result subc(Comment comment){
        System.out.println("成功进入控制器");
        return commentService.subComment(comment);
    }

}
